<template>
  <div class="error-page">
    <!-- 背景装饰 -->
    <div class="background-decoration"></div>

    <!-- 内容区域 -->
    <div class="content">
      <!-- 404 动画数字 -->
      <div class="error-code">
        <span class="digit">4</span>
        <span class="digit">0</span>
        <span class="digit not-found">4</span>
      </div>

      <!-- 描述文字 -->
      <h2 class="error-title">页面走丢了 🚫</h2>
      <p class="error-message">
        抱歉，您访问的页面不存在或已被移除。
      </p>

      <!-- 操作按钮 -->
      <div class="actions">
        <button class="btn btn-outline" @click="goBack">返回上一页</button>
        <RouterLink class="btn btn-primary" to="/">回到首页</RouterLink>
      </div>

      <!-- 小彩蛋 -->
      <p class="easter-egg" @click="toggleEasterEgg">
        {{ easterEgg ? '别戳了，快去工作吧！😄' : '点我有惊喜' }}
      </p>
    </div>

    <!-- 地球漂浮插图 -->
    <div class="illustration">
      <div class="earth"></div>
      <div class="satellite"></div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'

const router = useRouter()
const easterEgg = ref(false)

// 返回上一页
const goBack = () => {
  router.go(-1)
}

// 触发彩蛋
const toggleEasterEgg = () => {
  easterEgg.value = !easterEgg.value
}
</script>

<style scoped>
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  font-family: 'Segoe UI', Roboto, sans-serif;
  text-align: center;
  overflow: hidden;
  position: relative;
}

/* 装饰背景 */
.background-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle at 20% 30%, rgba(100, 180, 255, 0.1) 0%, transparent 25%),
  radial-gradient(circle at 80% 70%, rgba(255, 160, 122, 0.1) 0%, transparent 30%);
  pointer-events: none;
  z-index: 0;
}

.content {
  z-index: 1;
  padding: 2rem;
}

/* 404 数字样式 */
.error-code {
  font-size: 6rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  gap: 10px;
  text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1);
}

.digit {
  display: inline-block;
  transition: transform 0.3s ease;
}

.digit:hover {
  transform: translateY(-10px) rotate(10deg);
}

.not-found {
  color: #e74c3c;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.error-title {
  font-size: 2rem;
  color: #2c3e50;
  margin: 1rem 0;
}

.error-message {
  font-size: 1.1rem;
  color: #7f8c8d;
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* 按钮样式 */
.actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn {
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-outline {
  background-color: transparent;
  color: #3498db;
  border: 2px solid #3498db;
}

.btn-outline:hover {
  background-color: #3498db;
  color: white;
  transform: translateY(-2px);
}

/* 小彩蛋 */
.easter-egg {
  font-size: 0.9rem;
  color: #95a5a6;
  cursor: pointer;
  margin-top: 1rem;
  transition: color 0.3s;
}

.easter-egg:hover {
  color: #e74c3c;
}

/* 插图：地球与卫星 */
.illustration {
  position: absolute;
  bottom: 10%;
  right: 10%;
  width: 120px;
  height: 120px;
  opacity: 0.8;
  animation: float 6s ease-in-out infinite;
}

.earth {
  width: 60px;
  height: 60px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%233498db'/%3E%3Cpath d='M0,50 Q50,30 100,50 T200,50' fill='%232ecc71'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  border-radius: 50%;
  margin: 0 auto 10px;
  box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.satellite {
  width: 12px;
  height: 12px;
  background-color: #f39c12;
  border-radius: 50%;
  margin: 0 auto;
  box-shadow: 0 0 8px rgba(243, 156, 18, 0.6);
  animation: orbit 4s linear infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes orbit {
  0% {
    transform: translate(40px, -40px) rotate(0deg) translateX(20px) rotate(0deg);
  }
  100% {
    transform: translate(40px, -40px) rotate(360deg) translateX(20px) rotate(-360deg);
  }
}

/* 响应式 */
@media (max-width: 768px) {
  .error-code {
    font-size: 4rem;
  }

  .error-title {
    font-size: 1.5rem;
  }

  .actions {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 80%;
    max-width: 200px;
  }

  .illustration {
    width: 80px;
    height: 80px;
    bottom: 5%;
    right: 5%;
  }
}
</style>